<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数据类型</title>
</head>
<body>
<script>
    //原始类型:number String boolean undefined未定义型 null
    //typeof:用来推断数据类型
    var a =1;
    var b =3.14;
    console.log(a,typeof a,b,typeof b);
    var c = true;
    console.log(c,typeof c);
    var d = "hello";
    console.log(d,typeof d);
    var e ;
    console.log(e,typeof e);

    let obj={
        name:"张三",
        age:18
    }
    console.log(obj,typeof obj);
    console.log(obj.name);
    console.log(obj.age);
    obj.age=19;
    console.log(obj.age,typeof obj.name);
    obj.like="吃火锅";
    console.log(obj ,typeof obj);
    obj.play;
    console.log(obj.play);

    //JS数组
    let arr = ['周一',3,5.8,true];
    console.log(arr,typeof arr);
    console.log(arr[0],arr[1],arr[2],arr[3],arr[222]);

    //Boolean()将参数转为布尔类型
    console.log(Boolean(0));
    console.log(Boolean(undefined));
    console.log(Boolean(null));
    console.log(Boolean(NaN));
    console.log(Boolean(''));
    console.log(Boolean(' '));
    console.log(Boolean(1));
    console.log(Boolean('你好'));

    //Number()将参数转为数字类型
    console.log(Number(1),typeof Number(1));
    console.log(Number(0),typeof Number(0));
    console.log(Number(3),typeof Number(3));
    console.log(Number('3'),typeof Number('3'));
    console.log(Number('哈哈哈'),typeof Number('哈哈哈'));

</script>
</body>
</html>